<%-- 
    Document   : quotation_generate
    Created on : Jan 7, 2009, 3:25:54 PM
    Author     : hp02
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<table>
    <tr>
        <td class="menucon">
            <html:link action="/quotation_getquotations.do" title="Go to main.">Quotations</html:link>
        </td>
    </tr>
</table>
<html:messages id="messages" property="customMessage" message="true">
    <div class="heading4"><bean:write name="messages"/></div>
</html:messages>
<html:errors/>
<html:messages id="messages" property="message" message="true">
    <ul>
        <li><bean:write name="messages" filter="false"/></li>
    </ul>
</html:messages>
<html:form action="/quotation_new.do?step=save">
<table cellspacing="0">
    <html:hidden property="spdcf"/>
    <tr>
        <td colspan="6"><b><f:formatDate type="date" value="${date}"/></b></td>
    </tr>
    <tr>
        <td colspan="3" width="40%"><b>Customer Information</b></td>
        <td colspan="3" width="40%"><b>Quotation Information</b></td>
    </tr>
    <tr>
        <td>Name</td>
        <td>:</td>
        <td>${spdcf.customer.nama}</td>
        <td>Sales</td>
        <td>:</td>
        <td>${spdcf.inquery.sales.nama}</td>
    </tr>
    <tr>
        <td>Address</td>
        <td>:</td>
        <td>${spdcf.customer.alamat}</td>
        <td>Quot. Number</td>
        <td>:</td>
        <td>${spdcf.inquery.noQuotation}</td>
    </tr>
    <tr>
        <td>Phone</td>
        <td>:</td>
        <td>${spdcf.customer.telp}</td>
        <td>Project</td>
        <td>:</td>
        <td>${spdcf.inquery.project.nama}</td>
    </tr>
    <tr>
        <td>Fax</td>
        <td>:</td>
        <td>${spdcf.customer.fax}</td>
        <td>Prod. Specification</td>
        <td>:</td>
        <td>${spdcf.inquery.productSpec.nama}</td>
    </tr>
    <tr>
        <td>Email</td>
        <td>:</td>
        <td>${spdcf.customer.email}</td>
        <td>Standard</td>
        <td>:</td>
        <td>${spdcf.inquery.standartSpec.nama}</td>
    </tr>
    <tr>
        <td>Contact</td>
        <td>:</td>
        <td>${spdcf.customer.kontak}</td>
        <td>Finishing</td>
        <td>:</td>
        <td>${spdcf.inquery.finishing.nama}</td>
    </tr>
    <tr>
        <td colspan="3"></td>
        <td>Matrial</td>
        <td>:</td>
        <td><html:text property="matrial"/></td>
    </tr>
    <tr>
        <td colspan="3"></td>
        <td>Thickness</td>
        <td>:</td>
        <td><html:text property="thickness"/></td>
    </tr>
    <tr>
        <td colspan="3"></td>
        <td>Length</td>
        <td>:</td>
        <td><html:text property="lengt"/></td>
    </tr>
    <tr>
        <td colspan="3"></td>
        <td>Payment Term</td>
        <td>:</td>
        <td><html:text property="paymentTerm"/></td>
    </tr>
    <tr>
        <td colspan="3"></td>
        <td>Price</td>
        <td>:</td>
        <td><html:text property="price"/></td>
    </tr>
    <tr>
        <td colspan="3"></td>
        <td>Loco</td>
        <td>:</td>
        <td><html:text property="loco"/></td>
    </tr>
    <tr>
        <td colspan="3"></td>
        <td>Position Matrial</td>
        <td>:</td>
        <td><html:text property="positionMatrial"/></td>
    </tr>
    <tr>
        <td colspan="3"></td>
        <td>Delivery</td>
        <td>:</td>
        <td><html:text property="delivery"/></td>
    </tr>
    <tr>
        <td colspan="3"></td>
        <td>Validity Stock</td>
        <td>:</td>
        <td><html:text property="validityStock"/></td>
    </tr>
    <tr>
        <td colspan="3"></td>
        <td>Validity Price</td>
        <td>:</td>
        <td><html:text property="validityPrice"/></td>
    </tr>
    <tr>
        <td colspan="3"></td>
        <td>VAT</td>
        <td>:</td>
        <td><html:text property="vat" styleId="vat" onkeyup="updatevat(this.value,'quotation_new','vat2')"/> %</td>
    </tr>
    <tr>
        <td>Status</td>
        <td>:</td>
        <td colspan="4">
            <html:select property="status">
                <html:option value="0">Tender</html:option>
                <html:option value="1">Win</html:option>
                <html:option value="2">Lose</html:option>
            </html:select>
        </td>
    </tr>
    <tr>
        <td>Status Description</td>
        <td>:</td>
        <td colspan="4">
            <html:select property="statusDesc">
                <html:option value="1">Specification</html:option>
                <html:option value="2">Fee</html:option>
                <html:option value="3">Relationship</html:option>
                <html:option value="4">Price</html:option>
                <html:option value="5">Delivery</html:option>
                <html:option value="6">Payment</html:option>
                <html:option value="7">Brand</html:option>
            </html:select>
        </td>
    </tr>
    <tr><td><b>Quotation Items</b></td></tr>
    <tr>
        <td><html:link action="/quotation_newadditem.do?step=selectProduct&id=${spdcf.id}">Add Item</html:link></td>
    </tr>
    <tr>
        <td colspan="6">
            <table>
                <tr class="table_header">
                    <th>No.</th>
                    <th>Code</th>
                    <th>Name</th>
                    <th>Weight</th>
                    <th>Quantity</th>
                    <th>Sales Price</th>
                    <th>COGS+Margin</th>
                    <th>Discount(%)</th>
                    <th>Price</th>
                    <th>Action</th>
                </tr>
                <c:set var="x" value="0"/>
                <c:forEach items="${quotation.items}" var="item">
                    <c:if test="${item.priceList<item.priceHppAndMarginKeuangan}">
                        <tr class="critical">
                    </c:if>
                    <c:if test="${item.priceList==item.priceHppAndMarginKeuangan}">
                        <tr class="ok">
                    </c:if>
                    <c:if test="${item.priceList>item.priceHppAndMarginKeuangan}">
                        <tr class="good">
                    </c:if>
                        <td>${x+1}.</td>
                        <td>${item.produk.kode}</td>
                        <td>${item.produk.nama}</td>
                        <td>${item.produk.weight}</td>
                        <td>${item.jumlah}</td>
                        <td><f:formatNumber type="currency" maxFractionDigits="0" value="${item.priceList}" currencySymbol="Rp "/></td>
                        <td><f:formatNumber type="currency" maxFractionDigits="0" value="${item.priceHppAndMarginKeuangan}" currencySymbol="Rp "/></td>
                        <td>${item.disc}</td>
                        <td><f:formatNumber type="currency" maxFractionDigits="0" value="${item.priceList-(item.priceList*item.disc)/100}" currencySymbol="Rp "/></td>
                        <td>
                            <html:link action="/quotation_newupdateitem.do?step=load&id=${x}">Edit</html:link> |
                            <html:link action="/quotation_newadditem.do?step=deleteItem&id=${x}">Remove</html:link>
                        </td>
                    </tr>
                    <c:set var="x" value="${x+1}"/>
                </c:forEach>
                <c:if test="${x==0}">
                    <tr><td colspan="10" align="center">Inquiry have no item.</td></tr>
                </c:if>
                    <tr class="table_footer">
                        <td colspan="10">PT. Dhemar Nusantara - PT. Rahmi Ida Nusantara</td>
                    </tr>
                    <tr>
                        <td colspan="5" valign="top" rowspan="3">
                            <b>Note:</b><br/>
                            &raquo; Any reduction of quantity will invalid this quotation<br/>
                            &raquo; Price can change without prior notice<br/>
                            &raquo; If tou need further information please don't hesitate to contact<br/>
                            <i><b>Thank you for your kind attention</b></i>
                        </td>
                        <td colspan="2">TOTAL</td>
                        <td colspan="2" align="right"><f:formatNumber type="currency" maxFractionDigits="0" value="${total}" currencySymbol="Rp "/></td>
                    </tr>
                    <!--<tr>
                        <td colspan="2">DISCOUNT</td>
                        <td colspan="2"></td>
                    </tr>-->
                    <!--<tr>
                        <td colspan="2">TOTAL</td>
                        <td colspan="2"></td>
                    </tr>-->
                    <tr>
                        <td colspan="2">VAT</td>
                        <td colspan="2" align="right"><span id="vat2">0.0</span>%</td>
                    </tr>
                    <tr>
                        <td colspan="2">GRAND TOTAL</td>
                        <td colspan="2" align="right"><span id="grand_total"></span></td>
                        <td colspan="2" align="right"><html:button onmouseup="updategrandtotal(vat.value,'quotation_new','grand_total')" property="count" value="Count"/></td>
                    </tr>
                    <tr><th colspan="10" class="table_header">New item that you request to add.</th></tr>
                <c:set var="x" value="0"/>
                <c:forEach items="${listItem}" var="item">
                    <tr>
                        <td>${x+1}.</td>
                        <td>${item.produk.kode}</td>
                        <td>${item.produk.nama}</td>
                        <td>${item.produk.weight}</td>
                        <td>${item.jumlah}</td>
                        <td><f:formatNumber type="currency" maxFractionDigits="0" value="${item.priceList}" currencySymbol="Rp "/></td>
                        <td><f:formatNumber type="currency" maxFractionDigits="0" value="${item.priceHppAndMarginKeuangan}" currencySymbol="Rp "/></td>
                        <td>${item.disc}</td>
                        <td>
                            <f:formatNumber type="currency" maxFractionDigits="0" value="${item.priceList-(item.priceList*item.disc)/100}" currencySymbol="Rp "/></td>
                        <td>
                            <html:link action="/quotation_newupdateitem.do?step=load&id=${x}&scope=session">Edit</html:link> |
                            <html:link action="/quotation_newremoveitem.do?id=${x}">Remove</html:link>
                        </td>
                    </tr>
                    <c:set var="x" value="${x+1}"/>
                </c:forEach>
                <c:if test="${x==0}">
                    <tr><td colspan="10" align="center">Inquiry have no requested item.</td></tr>
                </c:if>
                <c:if test="${x!=0}">
                    <tr><td colspan="10"><html:link action="/quotation_newadditem?step=saveItem">Save requested Item</html:link></td></tr>
                </c:if>
                <tr class="table_footer">
                    <td colspan="10">PT. Dhemar Nusantara - PT. Rahmi Ida Nusantara</td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td colspan="6"><html:submit value="Save Now"/></td>
    </tr>
</table>
</html:form>
